package com.exc.rabbitmqboot.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * 定义死信：队列、交换机、队列绑定交换机、设置路由key
 */
@Configuration
public class DLXRabbitConfig {

    @Bean
    public Queue orderQueueDLX(){
        return new Queue("q.order.dlx", false, false, false, null);
    }

    @Bean
    public Exchange orderExchangeDLX() {
        return new DirectExchange("ex.order.dlx", false, false);
    }

    @Bean
    public Binding orderBindingDLX(){
        return BindingBuilder.bind(orderQueueDLX()).to(orderExchangeDLX()).with("order.pay.dlx").noargs();
    }
}
